/**
 * 
 */
package com.yidu.menuProject.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yidu.menuProject.common.Tool;
import com.yidu.menuProject.dao.FoodModelMapper;
import com.yidu.menuProject.dao.MealModelMapper;
import com.yidu.menuProject.dao.SiteModelMapper;
import com.yidu.menuProject.dao.TuserModelMapper;
import com.yidu.menuProject.model.FoodModel;
import com.yidu.menuProject.model.MealModel;
import com.yidu.menuProject.model.SiteModel;

/**
 * @author zoutian
 * date2018年7月12日
 * 
 */
@Service
public class personCenterImpl implements personCenter{
	@Resource
	private SiteModelMapper siteDao;
	@Resource  
	private TuserModelMapper userDao;                                
	@Resource
	private MealModelMapper mealDao;   
	@Resource  
	private FoodModelMapper foodDao;   
	
	   /**
		 * 收货地址的修改与显示
		 */
	@Override
	public List<SiteModel> findSite(String userName) {
		SiteModel site=new SiteModel();
		site.setUserName(userName);
		site.setIsva(2);
		List<SiteModel> list=siteDao.findSite(site);
		return list;
	}

	/**
	 * 查询用户密码
	 */
	@Override
	public String findPawd(String userId) {
		String userPawd=userDao.findPawd(userId);
		return userPawd;
	}
	/**
	 * 修改用户密码
	 */
	@Override
	public int updatePawd(String oper,String userId) {
		int rows=userDao.updatePawd(oper,userId);
		return rows;
	}

	@Override
	public int addArea(String userName, String userPhone,String siteName) {
		String userId=Tool.getRandomString();
		String siteId=Tool.getRandomString();
		int userRow=userDao.addTelephone(userId, userName, userPhone);
		SiteModel site=new SiteModel();
		site.setSiteId(siteId);
		site.setUserId(userId);
		site.setSiteName(siteName);
		site.setIsva(2);
		int siteRow=siteDao.addSite(site);
		if(userRow>0&&siteRow>0){
			return userRow;
		}else{
			return 0;
		}
	}
	/**
	 *删除用户收货信息 
	 */
	@Override
	public int deleResivAreaTele(String siteId) {
		//int tele=userDao.deleteResiverTelephone=(userId);
		Integer isva=1;
		int area=siteDao.deleteResiverArea(isva,siteId);
		if(area>0){
			return area;
		}
		return 0;
	}
	/**
	 * 修改用户收货地址
	 */
	@Override
	public int updateAreaTele(String siteName, String userPhone, String userId,String siteId) {
		int tele=userDao.updateAreaTele(userPhone, userId);
		int area=siteDao.updateAreaTele(siteName, siteId);
		if(tele>0&&area>0){
			return area;
		}else{
			return 0;
		}
	}
	/**
	 * 根据用户id查询用户收货地址
	 */
	@Override
	public List<SiteModel> findSiteById(String siteId) {
		List<SiteModel> list=siteDao.findSiteById(siteId);
		return list;
	}
	/**
	 * 查询我收藏的餐厅
	 */
	@Override
	public List<MealModel> findShop(String mealId) {
		List<MealModel> list=mealDao.findShop(mealId); 
		return list;
	}
	/**
	 * 查询我收藏的食品的方法
	 */
//	@Override
//	public List<FoodModel> findFoodResoved(String foodId) {
//		List<FoodModel> list=foodDao.findFoodResoved(foodId);
//		return list;
//	}
}